package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.PersonnelService;
import com.yixun.qfbao.apidto.AddPartnerReqDto;
import com.yixun.qfbao.apidto.AddPartnerResDto;
import com.yixun.qfbao.apidto.EditPartnerReqDto;
import com.yixun.qfbao.apidto.EditPartnerResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.AddPartnerReqVo;
import com.yixun.qfbao.vo.EditPartnerReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by Administrator on 2017/11/22.
 */
@Service("addPartnerHander")
public class AddPartnerHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(AddPartnerHander.class);
        @Autowired
        PersonnelService personnelService;
        @Override
        public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
            AddPartnerReqVo req = (AddPartnerReqVo)reqDto;
            AddPartnerReqDto editPartnerReqDto = req.getParams();
            BaseResponseDTO<AddPartnerResDto> res = new BaseResponseDTO<AddPartnerResDto>();
            AddPartnerResDto resDto = new AddPartnerResDto();
            try{
                resDto = personnelService.addPartner(editPartnerReqDto);
            } catch (Exception e) {
                logger.error("AddPartnerHander error: {}", e);
                resDto.setResult(ResultEnum.FAIL.getNo());
                resDto.setResultMsg("新增人员失败!");
            }
            res.setResData(resDto);
            res.setResult(resDto.getResult());
            return res;
        }
}
